package com.zhihuishu;

import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.SegToken;
import com.huaban.analysis.jieba.WordDictionary;

import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.Objects;

/**
 * @Author: wangjinliang
 * @Date: 2019/5/31 10:14
 */
public class JiebaBaseDemo {
    public static void main(String[] args) {
        URL resource = JiebaBaseDemo.class.getClassLoader().getResource("dicts/jieba.dict");
        if (Objects.isNull(resource)) {
            throw new RuntimeException("dicts/jieba.dict not found");
        }
        File file = new File(resource.getPath());
        WordDictionary.getInstance().loadUserDict(file);
        JiebaSegmenter segmenter = new JiebaSegmenter();
//        String result = "\uF06C喜欢形势与政策。没有理由，就是喜欢。毛概老师，讲课也有趣，如果不考试的话，就更好了！";
        String result = "中华人民共和国http://www.baidu.com666";
        List<SegToken> resultList = segmenter.process(result, JiebaSegmenter.SegMode.SEARCH);
        System.out.println(resultList);
    }
}
